if ($Triplet -ne "x64-linux") {
    return
}

. $PSScriptRoot/../end-to-end-tests-prelude.ps1

$args = $commonArgs + @("--overlay-triplets=$PSScriptRoot/../e2e-ports/compilertracking", "--binarysource=clear;files,$ArchiveRoot,readwrite")

# Test simple installation
Run-Kmpkg -TestArgs ($args + @("install", "kmpkg-hello-world-1"))
Throw-IfFailed
if (-Not (select-string "^triplet_abi [0-9a-f]+-[0-9a-f]+-[0-9a-f]+$" "$installRoot/x64-linux/share/kmpkg-hello-world-1/kmpkg_abi_info.txt")) {
    throw "Expected kmpkg-hello-world-1 to perform compiler detection"
}
Remove-Item -Recurse -Force $installRoot

Run-Kmpkg -TestArgs ($args + @("install", "kmpkg-hello-world-2"))
Throw-IfFailed
if (-Not (select-string "^triplet_abi [0-9a-f]+-[0-9a-f]+$" "$installRoot/x64-linux/share/kmpkg-hello-world-2/kmpkg_abi_info.txt")) {
    throw "Expected kmpkg-hello-world-2 to not perform compiler detection"
}
Remove-Item -Recurse -Force $installRoot

Run-Kmpkg -TestArgs ($args + @("install", "kmpkg-hello-world-2", "kmpkg-hello-world-1"))
Throw-IfFailed
if (-Not (select-string "^triplet_abi [0-9a-f]+-[0-9a-f]+-[0-9a-f]+$" "$installRoot/x64-linux/share/kmpkg-hello-world-1/kmpkg_abi_info.txt")) {
    throw "Expected kmpkg-hello-world-1 to perform compiler detection"
}
if (-Not (select-string "^triplet_abi [0-9a-f]+-[0-9a-f]+$" "$installRoot/x64-linux/share/kmpkg-hello-world-2/kmpkg_abi_info.txt")) {
    throw "Expected kmpkg-hello-world-2 to not perform compiler detection"
}
